#include<iostream>
#include<cstring>
using namespace std;
char arr[1100];
int main()
{
	int n;
	cin >> n;
	getchar();
	while (n--)
	{
		cin >> arr;
		int len = strlen(arr);
		if (len < 8 || len > 16) {
			cout << "NO" << endl;
			continue;
		}
		int flag1 = 0;
		int flag2 = 0;
		int flag3 = 0;
		int flag4 = 0;
		for (int i = 0; i < len; i++)
		{
			if (arr[i] >= 'a' && arr[i] <= 'z') {
				flag1=1;
			}
			else if(arr[i] >= 'A' && arr[i] <= 'Z') {
				flag2=1;
			}
			else if (arr[i] >= '0' && arr[i] <= '9') {
				flag3=1;
			}
			else if (arr[i] == '~' || arr[i] == '!' || arr[i] == '@' || arr[i] == '#'
				|| arr[i] == '$' || arr[i] == '%' || arr[i] == '^')
			{
				flag4=1;
			}
		}
		if ((flag1+flag2+flag3+flag4)>=3) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
	return 0;
}